//
//  HandViewController.m
//  Golf
//
//  Created by mrbradle on 10/26/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "HandViewController.h"

static int WIDTH = 100;
static int HEIGHT = 60;

@implementation HandViewController

@synthesize playerNameLabel, cardViews, xPosition, yPosition;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)setPlayer:(GolfGamePlayer*)player_ x:(int)xPos y:(int)yPos {
    
    player = player_;
    xPosition = xPos;
    yPosition = yPos;
    
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle



// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
    
    self.view = [[UIView alloc] initWithFrame:CGRectMake(xPosition, yPosition, WIDTH, HEIGHT)];
    
    //Add a label for the player's name
    playerNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(xPosition, yPosition, WIDTH, 20)];
    playerNameLabel.font = [UIFont fontWithName:@"Arial" size:12];
    playerNameLabel.textAlignment = UITextAlignmentCenter;
    playerNameLabel.textColor = [UIColor colorWithRed:0 green:0 blue:1 alpha:1];
    playerNameLabel.text = @"SUCCESS!";
    
    [self.view addSubview:playerNameLabel];
                       
    //Add four face-down cards

    CGRect cardPos[4];
    
    cardPos[0] = CGRectMake(xPosition+36, yPosition+20, 12, 16);
    cardPos[1] = CGRectMake(xPosition+52, yPosition+20, 12, 16);
    cardPos[2] = CGRectMake(xPosition+36, yPosition+40, 12, 16);
    cardPos[3] = CGRectMake(xPosition+52, yPosition+40, 12, 16);
    
    
    cardViews = [NSMutableArray arrayWithCapacity:4];
    for (int i = 0; i < 4; i++) {
        UIImageView* cardView = [[UIImageView alloc] initWithFrame:cardPos[i]];
        cardView.image = [UIImage imageNamed:@"b2fv.png"];
        [cardViews addObject:cardView];
        [self.view addSubview:cardView];
    }
    
}

- (void)loadView:(GolfGamePlayer*)player_ x:(int)xpos y:(int)ypos {
    
    
    
}



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
